var app = angular.module("BabbyApp", ['ngResource']);

app.filter('trusted', ['$sce', function($sce){
        return function (text){
            return $sce.trustAsHtml(text)
        };
    }]
);

app.factory("PostService", function($resource){
    return $resource("script/data.json");
});

app.controller('UserController', function($scope, PostService){
    $scope.user = {'name': 'Kelvin', 'login': true};
    $scope.post = {
        'title': 'This is my first page', 
        'keyword': 'first,page', 
        'content': "<p>This is my first page. Welcome to my home</p><p>sadf adfasdf sadfadsf asdfads sdfkadsgfn  fdsaf sadfa fasdf asdf sadf sadfa sfasd sadf gasd fsadf sdfsa dfas sadf sadf sadf sadfas fasdf asdfasd fasd fas fasdf asd fas df asdf as dfasdf asd fsadf asd fsa df asdfasdf sdaf asd fasdf</p> <p>When starting a project with peewee, it’s typically best to begin with your data model, by defining one or more Model classes:</p><p><pre><p>from peewee import *</p><p>db = SqliteDatabase('people.db')</p><p>class Person(Model):</p><p>&nbsp;&nbsp;name = CharField()</p><p>&nbsp;&nbsp;birthday = DateField()</p><p>&nbsp;&nbsp;is_relative = BooleanField()</p><p>&nbsp;&nbsp;class Meta:</p><p>&nbsp;&nbsp;&nbsp;&nbsp;database = db</p><p># This model uses the people.db database.</p></pre></p><p>Note Note that we named our model Person instead of People. This is a convention you should follow – even though the table will contain multiple people, we always name the class using the singular form.</p><p> There are lots of field types suitable for storing various types of data. Peewee handles converting between pythonic values those used by the database, so you can use Python types in your code without having to worry.Things get interesting when we set up relationships between models using foreign keys</p> ",
        'num_of_comments': 12,
        'create_time': '2017/05/20'
    };

    PostService.query({}, function(data){
        $scope.posts = data;
    })
});

